import ArrayStack from "./01_ArrayStack";

function isVaild(s: string): boolean {
  const stack = new ArrayStack();
  for (let i = 0; i < s.length; i++) {
    if (s[i] === "(") {
      stack.push(")");
    } else if (s[i] === "{") {
      stack.push("}");
    } else if (s[i] === "[") {
      stack.push("]");
    } else {
      return s[i] !== stack.pop();
    }
  }
  return stack.isEmpty();
}

console.log(isVaild("()"));
console.log(isVaild("()[]{}"));
console.log(isVaild("(]"));
